//
//  ChildrenTwoViewController.m
//  MM
//
//  Created by 王晨辉 on 15/5/15.
//  Copyright (c) 2015年 王晨辉. All rights reserved.
//

#import "ChildrenTwoViewController.h"

@interface ChildrenTwoViewController ()

@end

@implementation ChildrenTwoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //设置导航栏头文字
    self.navigationItem.title = @"园内报告";
    //设置导航栏背景颜色
    [self.navigationController.navigationBar setBarTintColor:[GetFileModel colorWithHexString:@"#44afd7" alpha:1]];
    //设置导航栏字体颜色
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName,nil]];
    self.view.backgroundColor = [UIColor whiteColor];
    
    //自定义左右按钮
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setBackgroundImage:[UIImage imageNamed:@"_0000_返回.png"]
                      forState:UIControlStateNormal];
    [button addTarget:self action:@selector(turntolast)
     forControlEvents:UIControlEventTouchUpInside];
    button.frame = CGRectMake(0, 0, 20, 15);
    
    UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
    
    self.navigationItem.leftBarButtonItem = menuButton;
    

    [self subView];
    
}
-(void)turntolast{
    
    [self dismissViewControllerAnimated:YES completion:nil];
    
    
}
-(void)subView{
    
    
    
    
    NSDictionary *paras_babyReportDetails = @{@"reportId":self.reportId};
    [UserDAL getBabyReportDetailsWithParams:paras_babyReportDetails withBlock:^(NSDictionary *data, NSError *error) {
        
        if (data) {
            
            
            ////NSLog(@"%@",data);
            
            NSString * contents = [data objectForKey:@"contents"];
            NSString * timeStamp = [data objectForKey:@"timeStamp"];

            _oLab = [[UILabel alloc]init];
            _oLab.frame = CGRectMake(0, NavbarHight-20, SCREEN_WIDTH, SCREEN_WIDTH/3.7);
            _oLab.text = @" 评 测 报 告";
            _oLab.font = [UIFont systemFontOfSize:18];
            _oLab.textAlignment = NSTextAlignmentCenter;
            [self.view addSubview:_oLab];
            
            
            UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0, NavbarHight-40+SCREEN_WIDTH/3.7, SCREEN_WIDTH, 1)];
            lineView.backgroundColor = UIColorWithRGBA(215, 215, 215, 1);
            [self.view addSubview:lineView];
            
            
            _tLab = [[UILabel alloc]initWithFrame:CGRectMake(0, NavbarHight-40+SCREEN_WIDTH/3.7+11, SCREEN_WIDTH, 20)];
            _tLab.text = timeStamp;
            _tLab.font = [UIFont systemFontOfSize:11];
            _tLab.textAlignment = NSTextAlignmentCenter;
            // _tLab.backgroundColor = [UIColor redColor];
            [self.view addSubview:_tLab];
            
            //用textFild
            UILabel * testlable = [[UILabel alloc]initWithFrame:CGRectMake(10,20,200,20)];
            NSString * tstring =contents;
            testlable.numberOfLines =0;
            UIFont * tfont = [UIFont systemFontOfSize:12];
            testlable.font = tfont;
            testlable.lineBreakMode =NSLineBreakByTruncatingTail ;
            testlable.text = tstring ;
            [testlable setBackgroundColor:[UIColor whiteColor]];
            [self.view addSubview:testlable];
            CGSize size =CGSizeMake(SCREEN_WIDTH-20,MAXFLOAT);
            NSDictionary * tdic = [NSDictionary dictionaryWithObjectsAndKeys:tfont,NSFontAttributeName,nil];
            CGSize  actualsize =[tstring boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin  attributes:tdic context:nil].size;
            testlable.frame =CGRectMake(10,NavbarHight+30+SCREEN_WIDTH/3.7, actualsize.width, actualsize.height);
            [self.view addSubview:testlable];
            
            
        }else{
            
            

            NSString * msg = [data objectForKey:@"msg"];
            alert(msg);
            //失败
            
            
        }
        
        
    }];
    
    
    
    
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

{
    NSString *msg = [[NSString alloc] initWithFormat:@"您点击的是第%d个按钮!",buttonIndex];
    ////NSLog(@"msg:%@",msg);
    if (buttonIndex == 0) {
        
        [self dismissViewControllerAnimated:YES completion:nil];
        ////NSLog(@"1111111");
        
    }else if(buttonIndex == 1){
        
        
        ////NSLog(@"2222222");
        
        
    }
    
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
